<template>
  <mapVue
    :bg-name="store.getCurrentComName"
    :points="points"
    @show="onShow"
  ></mapVue>

  <!-- 通用 -->
  <dialog_common v-model:show="show" :data="node"></dialog_common>
</template>
<script setup>
import { computed, ref } from "vue";
import { userStore } from "@/store/modules/userStore";
import mapVue from "./components/map.vue";
import { devicePoint, labelMap } from "@/utils";
import dialog_common from "./components/dialog/dialog_common.vue";

const store = userStore();
const show = ref(false);
const node = ref({});

const points = computed(() => {
  return devicePoint[store.getCurrentComName];
});

function onShow(item) {
  console.log("----------", item.index);
  // return;
  if (
    (!item.isComponent && !item.icon) ||
    item.opt ||
    item.icon?.indexOf("SBN") > -1 ||
    item.icon?.indexOf("XFN") > -1
  ) {
    return;
  }

  show.value = true;
  if (item.label === "空调") {
    node.value = {
      deviceCode: "TK/PY-A1",
      deviceName: item.label || "",
      currentComName: store.getCurrentComName,
      index: item.index,
    };
  } else if (item.label === "风机") {
    node.value = {
      deviceCode: item.deviceCode,
      deviceName: item.label || "",
      currentComName: store.getCurrentComName,
      index: item.index,
    };
  } else if (item.label === "自动扶梯") {
    node.value = {
      deviceCode: "CZF7-1",
      deviceName: item.label || "",
      currentComName: store.getCurrentComName,
      index: item.index,
    };
  } else {
    let imgName = item.icon?.split("/")?.pop()?.split("_")?.shift();
    const deviceName = labelMap[imgName];
    node.value = {
      deviceCode: item.label || "TK/KT-1514-B1",
      deviceName: deviceName || "",
      currentComName: store.getCurrentComName,
      index: item.index,
    };
  }
}
</script>
<style scoped lang="less"></style>
